//
// Created by xana/cuixianming on 2018-01-22.
// Copyright (c) 2018 Keep. All rights reserved.
//

#include "android_log.h"

#define LINE_SZ 1024
void log_anyway(void *ptr, int level, const char *fmt, va_list vl)
{
    static int print_prefix = 1;
    static char line[LINE_SZ];
    unsigned tint = 0;

    if (level >= 0) {
        tint = level & 0xff00;
        level &= 0xff;
    }

    memset(line, '\0', LINE_SZ);
//    av_log_format_line(ptr, level, fmt, vl, line, LINE_SZ, &print_prefix);

    switch (level) {
        case AV_LOG_QUIET:
            break;
        case AV_LOG_PANIC:
        case AV_LOG_FATAL:
            logf("%s", line);
            break;
        case AV_LOG_ERROR:
            loge("%s", line);
            break;
        case AV_LOG_WARNING:
            logw("%s", line);
            break;
        case AV_LOG_INFO:
            logi("%s", line);
            break;
        case AV_LOG_VERBOSE:
            logv("%s", line);
            break;
        case AV_LOG_DEBUG:
        case AV_LOG_TRACE:
            logd("%s", line);
            break;
    }
}

void printf_log(const char* fmt, ...) {
    va_list ap;
    va_start(ap, fmt);
    log_anyway(NULL, AV_LOG_INFO, fmt, ap);
    va_end(ap);
}